package pe.com.cineplanet.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver;

import pe.com.cineplanet.service.Service;

public class AlmacenController extends MultiActionController {

	Service service;
	
	private Class<?> commandClass;  
	
	public AlmacenController()
    {
        ParameterMethodNameResolver resolver = new ParameterMethodNameResolver();
        resolver.setParamName("method");
        resolver.setDefaultMethodName("buscar");
        setMethodNameResolver(resolver);
    }
	

	public ModelAndView buscarRubro(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
		
		return new ModelAndView("almacen/rubro/buscar");
	} 

	public ModelAndView nuevaGuia(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
		return new ModelAndView("guia/nuevo");

    } 
	
	public ModelAndView guia(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
		return new ModelAndView("almacen/guia");

    } 
	
	public ModelAndView guiaVentas(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
		return new ModelAndView("almacen/guia/ventas");

    } 
	
	public ModelAndView kardex(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
		return new ModelAndView("almacen/kardex");

    } 
	
	
	public Object getCommandObject(HttpServletRequest request)
	throws Exception {
		Object command = formBackingObject(request);
		bind (request, command);
		return command;
	}
	
	protected Object formBackingObject(HttpServletRequest request)
	throws Exception {
		return commandClass.newInstance();
	}

	public Class<?> getCommandClass() {
		return commandClass;
	}

	public void setCommandClass(Class<?> commandClass) {
		this.commandClass = commandClass;
	}
	
	public void setService(Service service) {
		this.service = service;
	}
	
	public Service getService() {
		return service;
	}
	

}
